const users = {
  admin: {
    token: "admin-token",
    roles: ["admin"],
    avatar:
      "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
    name: "超级管理员",
    permissions: ["sys.btn.add", "sys.btn.delete", "sys.btn.query"],
    indexPage: "/index",
  },
  editor: {
    token: "editor-token",
    roles: ["editor"],
    avatar:
      "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
    name: "普通用户",
    permissions: ["sys.btn.query"],
    indexPage: "/index",
  },
};

module.exports = [
  // user login
  {
    url: "/admin/user/login",
    type: "post",
    response: () => {
      return {
        code: 200,
        data: users.admin,
      };
    },
  },

  // get user info
  {
    url: "/admin/user/info.*",
    type: "get",
    response: () => {
      //const { token } = config.query;
      //const info = users[token];
      const info = users["admin-token"];
      // mock error
      if (!info) {
        return {
          code: 50008,
          message: "Login failed, unable to get user details.",
        };
      }

      return {
        code: 200,
        data: info,
      };
    },
  },

  // user logout
  {
    url: "/admin/user/logout",
    type: "post",
    response: () => {
      return {
        code: 200,
        data: "success",
      };
    },
  },
];
